package com.glsc.ngateway.platform.repo.costallocation;

import com.glsc.ngateway.platform.domain.costallocation.DepCostAllocation;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Set;

@Repository
public interface DepCostAllocationRepo extends JpaRepository<DepCostAllocation, Long>, JpaSpecificationExecutor<DepCostAllocation> {

    @Transactional
    @Modifying
    @Query(value = "delete from t_dep_costallocation u where u.vc_systeminfo_id = :systemInfoId",nativeQuery = true)
    void deleteBySystemInfoId(@Param("systemInfoId") long systemInfoId);


    @Query(value = "select u  from DepCostAllocation u where u.systemInfoId = :systemInfoId")
    List<DepCostAllocation> queryBySystemInfoId(@Param("systemInfoId") long systemInfoId);


    @Query(value = "select u  from DepCostAllocation u where u.systemInfoId in :systemInfoIdSet")
    List<DepCostAllocation> queryBySystemInfoId(@Param("systemInfoIdSet") Set<Long> systemInfoIdSet);
}
